<template>
	<view class="content">
		<u-sticky style="top:0px;">
			<u-swiper autoplay="true" height="250px" circular="true" radius="0" :list="list1" @change="change" @click="click">
			</u-swiper>
		</u-sticky>
		<view class="u-card">
			<view style="margin-left: 50rpx;margin-right: 50rpx;margin-bottom: 20rpx;">
				<u-subsection :list="list" mode="subsection" :current="curNow" @change="sectionChange"></u-subsection>
			</view>

			<u-list @scrolltolower="scrolltolower">
				<u-list-item v-for="(item, index) in indexList" :key="index">
					<u-cell center>
						<template #title>
							<view class="cell-title">
								<text class="cell-title-item" style="font-weight: bold;">名称</text>
								<view class="cell-title-item">
									<u-icon name="clock" color="#2979ff" size="18"></u-icon>
									<text>50分钟</text>
								</view>
								<view class="cell-title-item" style="align-items: flex-end;">
									<font style="font-size: 12rpx;color: #EC6A06;">￥</font>
									<font style="font-size: 18px;color: #EC6A06;margin-right: 10rpx;">299</font>
									<font style="text-decoration: line-through;color: gray;font-size: 12rpx;">399</font>
									<font style="color: gray;font-size: 12rpx;">(已售出499)</font>
								</view>
							</view>
						</template>
						<template #icon>
							<u-avatar shape="square" size="80" :src="item.url" customStyle="margin: -3px 5px -3px 0">
							</u-avatar>
						</template>
						<template #right-icon>
							<u-button type="primary" shape="circle" size="small" text="去选择"></u-button>
						</template>
					</u-cell>
				</u-list-item>
			</u-list>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
				currentNum: 0,
				list: ['全部项目', '女士项目'],
				curNow: 0,
				list1: [
					'https://cdn.uviewui.com/uview/swiper/swiper1.png',
					'https://cdn.uviewui.com/uview/swiper/swiper2.png',
					'https://cdn.uviewui.com/uview/swiper/swiper3.png',
				],
				indexList: [],
				urls: [
					'https://cdn.uviewui.com/uview/album/1.jpg',
					'https://cdn.uviewui.com/uview/album/2.jpg',
					'https://cdn.uviewui.com/uview/album/3.jpg',
					'https://cdn.uviewui.com/uview/album/4.jpg',
					'https://cdn.uviewui.com/uview/album/5.jpg',
					'https://cdn.uviewui.com/uview/album/6.jpg',
					'https://cdn.uviewui.com/uview/album/7.jpg',
					'https://cdn.uviewui.com/uview/album/8.jpg',
					'https://cdn.uviewui.com/uview/album/9.jpg',
					'https://cdn.uviewui.com/uview/album/10.jpg',
				]
			}
		},
		onLoad() {
			this.loadmore()
		},
		methods: {
			sectionChange(index) {
				this.curNow = index;
			},
			change(e) {
				console.log('change', e);
			},
			click(e) {
				console.log('click', e);
			},
			scrolltolower() {
				this.loadmore()
			},
			loadmore() {
				for (let i = 0; i < 30; i++) {
					this.indexList.push({
						url: this.urls[uni.$u.random(0, this.urls.length - 1)]
					})
				}
			}
		}
	}
</script>

<style scoped>
	.content {
		background-color: whitesmoke;
	}

	.u-card {
		margin: 10rpx;
		padding: 10rpx;
		background-color: white;
		border-radius: 10rpx 10rpx 0rpx 0rpx;
	}

	.cell-title {
		height: 100%;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.cell-title-item {
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-bottom: 5px;
	}
</style>
